export function formatTimeDifference(timestamp) {
    const now = Date.now();
    const diff = now - timestamp;

    // 时间单位
    const oneMinute = 60 * 1000;
    const oneHour = 60 * oneMinute;
    const oneDay = 24 * oneHour;
    const oneMonth = 30 * oneDay; // 近似值，实际一个月可以有28-31天
    const threeMonths = 3 * oneMonth;

    if (diff < oneMinute) {
        return '1分钟';
    } else if (diff < oneHour) {
        const minutes = Math.floor(diff / oneMinute);
        return `${minutes}分钟`;
    } else if (diff < oneDay) {
        const hours = Math.floor(diff / oneHour);
        return `${hours}小时`;
    } else if (diff < oneMonth) {
        const days = Math.floor(diff / oneDay);
        return `${days}天`;
    } else if (diff < threeMonths) {
        const months = Math.floor(diff / oneMonth);
        return `${months}月`;
    } else {
        return '很久';
    }
}
export function goToHome(){
	uni.showModal({
		title:'提示',
		content:'页面有误将返回首页',
		showCancel:false,
		success(resp) {
			if(resp.confirm) uni.reLaunch({
				url:'/pages/index/index'
			});
		}
	})
}